< previous page page_602 next page >

Page 602
0602-01.jpg
Figure 27.8
The SQL Server dialog box requires you to
specify the server where the information is located.
The DSN screens also give you the ability to Configure or Remove ODBC data sources. To modify a data source, select the data source and then click the Configure button. This presents you with the same dialog box that you used initially to set up the data source. To delete a data source, select it and then click the Remove button.
Using the DAOs to Create an ODBC Source
You are not limited to setting up data sources interactively. There are times, such as application installation, where you might want to add a data source with code. For this purpose, you can use the RegisterDatabase method of the DBEngine object.
Here is the syntax of the RegisterDatabase method:
DBEngine.RegisterDatabase dbname, driver, silent, attributes
Table 27.1 defines the parameters used in the RegisterDatabase method.
Table 27.1 Parameters of the RegisterDatabase Method
ParameterDefinition
dbNameA user-definable string expression that specifies the data source name (for example, "MyDatabase").
driverA string expression that indicates the installed driver's name (for example, ORACLE) as listed in the ODBC Drivers tab of the ODBC Administrator.
silentTrue specifies that the next parameter (attributes) indicates all connection information. False specifies to display the Driver Setup dialog box and ignore the contents of the attributes parameter.
attributesAll connection information for using the ODBC driver. This parameter is ignored if silent is set to False.

The following code sample illustrates how the RegisterDatabase method is used to create a link to an Access database. Before attempting to use the Data Access Objects, remember to add the appropriate reference:

 
< previous page page_602 next page >